package com.sdstc.modules.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.sdstc.modules.eneity.OrgEntity;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @author ：wk
 * @date ：Created in 2022/10/21 14:52
 */
@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class OrgTreeVo implements Serializable,Cloneable {

    private static final long serialVersionUID=1L;

    private String id;

    private String pid;

    private String orgName;

    private String simpleName;

    // 机构级别
    private String orgLevel;

    // 机构类型
    private String orgType;

    /**
     * 预设编制
     */
    // 行政
    private Integer organizationAdmin;
    // 单列
    private Integer organizationSingle;
    // 工勤
    private Integer organizationWork;
    // 事业
    private Integer organizationCause;

    /**
     * 职数及配备 start
     */
    // 部门领导正职
    private Integer departmentLead;

    // 部门领导副职
    private Integer departmentLeadDeputy;

    // 与部门领导同级别的其他领导
    private Integer sameDepartmentLead;

    // 内设机构领导正职
    private Integer internalLead;

    // 内设机构领导副职
    private Integer internalLeadDeputy;

    // 与内设机构领导同级别的其他领导
    private Integer sameInternalLead;

    /**
     * 职数及配备 end
     */

    private List<OrgTreeVo> children;


    public static  Integer orgCount(OrgTreeVo orgTreeVo){
        return orgTreeVo.getOrganizationAdmin() + orgTreeVo.getOrganizationWork() + orgTreeVo.getOrganizationCause() + orgTreeVo.getOrganizationSingle();
    }

    public static OrgTreeVo getInstance(OrgEntity orgEntity){
        OrgTreeVo orgTreeVo = new OrgTreeVo();
        BeanUtils.copyProperties(orgEntity,orgTreeVo);
        return orgTreeVo;
    }

    @Override
    public OrgTreeVo clone() throws CloneNotSupportedException {
        return (OrgTreeVo) super.clone();
    }
}
